﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using InstantSpine.Core.Properties;
using System.Runtime.Serialization;
using InstantSpine.Core.MaterialModels;

namespace InstantSpine.Core
{
    /// <summary>
    /// The fibrous part of the annulus described by eight distinct layers of AnnulusFiberLayer
    /// </summary>
    /// <remarks>Corresponds to eight n x 2 arrays of stress-strain pairs in ParaSpine</remarks>
    [DataContract]
    public sealed class LayeredAnnulusFibers : MaterialViewModel
    {
        public ObservableCollection<AnnulusFiberLayer> Layers {
            get {
                return new ObservableCollection<AnnulusFiberLayer>
                    { Layer1, Layer2, Layer3, Layer4, Layer5, Layer6, Layer7, Layer8 };
            }
        }

        /// <summary>
        /// material properties for layer 1 (outermost)
        /// </summary>
        /// <remarks>ParamSpine parameter: mpAnnulusFiberLayer1 (n x 2 array of n stree-strain pairs)</remarks>
        [DataMember]
        public AnnulusFiberLayer Layer1 { get; private set; }
        
        /// <summary>
        /// material properties for layer 2
        /// </summary>        
        /// <remarks>ParamSpine parameter: mpAnnulusFiberLayer2 (n x 2 array of n stree-strain pairs)</remarks>
        [DataMember]
        public AnnulusFiberLayer Layer2 { get; private set; }

        /// <summary>
        /// material properties for layer 3
        /// </summary>        
        /// <remarks>ParamSpine parameter: mpAnnulusFiberLayer3 (array of 27 stree-strain pairs)</remarks>
        [DataMember]
        public AnnulusFiberLayer Layer3 { get; private set; }

        /// <summary>
        /// material properties for layer 4
        /// </summary>        
        /// <remarks>ParamSpine parameter: mpAnnulusFiberLayer4 (array of 27 stree-strain pairs)</remarks>
        [DataMember]
        public AnnulusFiberLayer Layer4 { get; private set; }

        /// <summary>
        /// material properties for layer 5
        /// </summary>        
        /// <remarks>ParamSpine parameter: mpAnnulusFiberLayer5 (array of 27 stree-strain pairs)</remarks>
        [DataMember]
        public AnnulusFiberLayer Layer5 { get; private set; }

        /// <summary>
        /// material properties for layer 6
        /// </summary>        
        /// <remarks>ParamSpine parameter: mpAnnulusFiberLayer6 (array of 27 stree-strain pairs)</remarks>
        [DataMember]
        public AnnulusFiberLayer Layer6 { get; private set; }

        /// <summary>
        /// material properties for layer 7
        /// </summary>        
        /// <remarks>ParamSpine parameter: mpAnnulusFiberLayer7 (array of 27 stree-strain pairs)</remarks>
        [DataMember]
        public AnnulusFiberLayer Layer7 { get; private set; }

        /// <summary>
        /// material properties for layer 8 (innermost)
        /// </summary>        
        /// <remarks>ParamSpine parameter: mpAnnulusFiberLayer8 (array of 27 stree-strain pairs)</remarks>
        [DataMember]
        public AnnulusFiberLayer Layer8 { get; private set; }

        public LayeredAnnulusFibers(
            AnnulusFiberLayer layer1,
            AnnulusFiberLayer layer2,
            AnnulusFiberLayer layer3,
            AnnulusFiberLayer layer4,
            AnnulusFiberLayer layer5,
            AnnulusFiberLayer layer6,
            AnnulusFiberLayer layer7,
            AnnulusFiberLayer layer8,
            string name = null): base(name) {
            this.Layer1 = layer1;
            this.Layer2 = layer2;
            this.Layer3 = layer3;
            this.Layer4 = layer4;
            this.Layer5 = layer5;
            this.Layer6 = layer6;
            this.Layer7 = layer7;
            this.Layer8 = layer8;
        }

        public LayeredAnnulusFibers(string name = null) : base(name) {
            this.Layer1 = new AnnulusFiberLayer(Resources.AnnulusLayer1);
            this.Layer2 = new AnnulusFiberLayer(Resources.AnnulusLayer2);
            this.Layer3 = new AnnulusFiberLayer(Resources.AnnulusLayer3);
            this.Layer4 = new AnnulusFiberLayer(Resources.AnnulusLayer4);
            this.Layer5 = new AnnulusFiberLayer(Resources.AnnulusLayer5);
            this.Layer6 = new AnnulusFiberLayer(Resources.AnnulusLayer6);
            this.Layer7 = new AnnulusFiberLayer(Resources.AnnulusLayer7);
            this.Layer8 = new AnnulusFiberLayer(Resources.AnnulusLayer8);
        }

        // required for XML serialization to work
        public LayeredAnnulusFibers() : this(null) { }
    }
}
